package com.spring.security.client.browser.config;

import com.spring.security.client.browser.logout.SpringLogoutSuccessHandler;
import com.spring.security.core.properties.SecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

/**
 * 浏览器环境下扩展点配置，配置在这里的bean，业务系统都可以通过声明同类型或同名的bean来覆盖安全模块默认的配置。
 *
 * @author seabed_moon
 */
@Configuration
public class BrowserSecurityBeanConfig {


    @Autowired
    private SecurityProperties securityProperties;


    /**
     * 退出时的处理策略配置
     *
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(LogoutSuccessHandler.class)
    public LogoutSuccessHandler logoutSuccessHandler(){
        return new SpringLogoutSuccessHandler(securityProperties.getBrowser().getSignOutUrl());
    }

}
